package com.global.vo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 存储每一行中的值信息
 * @author zly601436
 *
 */
public class RowValuesProperties implements Serializable {

	private static final long serialVersionUID = 6553276547669797530L;

	private String message;
	
	private Set<CellValueProperties> rowCells;

	/**
	 * 初始化列数
	 * @param cellCount
	 */
	public RowValuesProperties(final int cellCount) {
		rowCells = new HashSet<CellValueProperties>(cellCount);
	}
	
	/**
	 * 返回每一行中的字段数
	 * @return int
	 */
	public int getCellCount() {
		return rowCells.size();
	}

	/**
	 * 返回行的值清单
	 * @return
	 */
	public Set<CellValueProperties> getCellValuePropertiesList() {
		return rowCells;
	}
	
	/**
	 * 返回值信息
	 * @param key 栏位名称
	 * @return CellValueProperties
	 */
	public CellValueProperties getCellValueProperties(String key) {
		Iterator<CellValueProperties> iterator = rowCells.iterator();
		while(iterator.hasNext()){
			CellValueProperties next = iterator.next();
			if(next.getKey().equalsIgnoreCase(key)){
				return next;
			}
		}
		
		return null;
	}

	/**
	 * 增加栏位的值信息
	 * @param cellValueProperties
	 * @return boolean true 表示添加成功
	 */
	public boolean add(CellValueProperties cellValueProperties) {
		return rowCells.add(cellValueProperties);
	}
	
	/**
	 * 从值清单中删除某个栏位
	 * @param cellValueProperties
	 * @return boolean true 表示删除成功
	 */
	public boolean remove(CellValueProperties cellValueProperties){
		return rowCells.remove(cellValueProperties);
	}
	
	/**
	 * 清空值清单
	 */
	public void clear(){
		rowCells.clear();
	}
	
	public void setMessage(String message){
		this.message = message;
	}	
	public String getMessage(){
		return message;
	}
}
